<?php

/**
 * ECSHOP 列出所有分类及品牌
 * ============================================================================
 * * 版权所有 2005-2012 上海商派网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.ecshop.com；
 * ----------------------------------------------------------------------------
 * 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和
 * 使用；不允许对程序代码以任何形式任何目的的再发布。
 * ============================================================================
 * $Author: liubo $
 * $Id: catalog.php 17217 2011-01-19 06:29:08Z liubo $
*/

define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

require(dirname(__FILE__) . '/Classes/PHPExcel.php');
require(dirname(__FILE__). '/Classes/PHPExcel/IOFactory.php');

if ((DEBUG_MODE & 2) != 2)
{
    $smarty->caching = true;
}
$action  = isset($_REQUEST['act']) ? trim($_REQUEST['act']) : 'default';


if ($action == 'default')
{
   
    // $arry = array();
    // $arry['aa'] = 11;
    // $arry['bb'] = 22;
    // $arry['cc'] = 33;

    // while ($row = $arry) {
    //    print_r($row);
    // }

     $filter['is_upload'] = $_REQUEST['p'] ? 1 : 0;

     $sql = "SELECT last_update FROM " . $ecs->table('cql') . " ORDER BY order_id DESC LIMIT 1";
     $lastUpdate = $db->getOne($sql);
   
    $smarty->assign('lastUpdate',   $lastUpdate);
    $order_list = order_list();
    $smarty->assign('order_list',   $order_list['orders']);
    $smarty->assign('filter',       $order_list['filter']);
    $smarty->assign('record_count', $order_list['record_count']);
    $smarty->assign('page_count',   $order_list['page_count']);
    $smarty->assign('total_price',   $order_list['total_price']);
    $smarty->assign('is_upload',   $filter['is_upload']);

    


   // print_r(order_list());
  $smarty->display('cql2.dwt');
}




/*------------------------------------------------------ */
//-- 批量上传：处理
/*------------------------------------------------------ */

elseif ($action  == 'upload')
{
         if (!empty ( $_FILES['file_stu']['name'] )) 

            {
                    $tmp_file = $_FILES['file_stu']['tmp_name'];
                    $file_types = explode( ".", $_FILES ['file_stu']['name'] );
                    $file_type = $file_types[count($file_types) - 1];

                    /*判别是不是.xls文件，判别是不是excel文件*/
                    // if (strtolower( $file_type ) != "xls")              
                    // {
                    //     die('不是Excel文件，重新上传');
                    //     //$this->error('不是Excel文件，重新上传');
                    // }
                   // print_r ('<pre>');

                     $file_data = importExecl($tmp_file);
                     
                    //$is_alimama = $file_data[1][A] == '创建时间' ? true : false;
                    //$last_data = end($file_data);
                   // print_r (end($file_data));
                        /* 获取商品good id */
                       // $max_id = $db->getOne("SELECT MAX(order_id) + 1 FROM ".$ecs->table('cql'));
                          /* 循环插入商品数据 */
                          if(1){
                              // print_r("<pre/>");
                               
                                array_shift($file_data);
                               // sort($file_data);
                               //  print_r($file_data);

                               foreach ($file_data as $key => $value) {

                                    $sql = "SELECT id " .
                                    " FROM " .$GLOBALS['ecs']->table('product') .
                                    " WHERE title = '$value[A]'";
                                    $pid = $GLOBALS['db']->getOne($sql);

                                    $sql = "DELETE FROM " . $ecs->table('product') .
                                                " WHERE id = '$pid'  ";
                                    $db->query($sql, 'SILENT');

                                     $sql = "DELETE FROM " . $ecs->table('plist') .
                                                " WHERE listid = '$pid'  ";
                                    $db->query($sql, 'SILENT');
                               }

                                foreach ($file_data AS $key => $value)
                                {
                                    // 合并
                                    $field_arr = array(
                                        'addtime'   => date("Y-m-d H:i:s"),
                                        'updatetime'   => date("Y-m-d H:i:s"),
                                    );
                                 //print_r("<pre/>");
                                //  print_r($key);
                                //  print_r($value);
                                       
                                        
                                           
                                            
                                              
                                            

                                                $field_arr['title'] = $value['A'];
                                                $field_arr['description'] = $value['A'];
                                                $field_arr['class1'] = 3;
                                                $field_arr['class2'] = 0;
                                                $field_arr['class3'] = 0;
                                                $field_arr['imgurl'] = $value['G'];
                                                $field_arr['imgurls'] = '../upload/pthumb.jpg';
                                                $field_arr['displaytype'] = 1;
                                                $field_arr['lang'] = 'cn';
                                               
                                            
                                                $db->autoExecute($ecs->table('product'), $field_arr, 'INSERT');
                                                $back_id = $GLOBALS['db']->insert_id();

                                                
                                                foreach ($value AS $key => $svalue)
                                                 {
                                                     if($key == 'F'){
                                                         break;
                                                     }
                                                     $field_arrs['listid'] = $back_id ;

                                                        switch ($key) {
                                                            case 'A':
                                                                $field_arrs['paraid'] = 1 ;
                                                                break;
                                                            case 'B':
                                                                $field_arrs['paraid'] = 2 ;
                                                                break;
                                                                case 'C':
                                                                $field_arrs['paraid'] = 3 ;
                                                                break;
                                                                case 'D':
                                                                $field_arrs['paraid'] = 162 ;
                                                                break;
                                                                case 'E':
                                                                $field_arrs['paraid'] = 163 ;
                                                                break;
                                                            default:
                                                                # code...
                                                                break;
                                                        }
                                                       

                                                        $field_arrs['info'] = $svalue;
                                                        $field_arrs['module'] = 3;
                                                       
                                                        $field_arrs['lang'] = 'cn';
                                                    
                                                    
                                                        $db->autoExecute($ecs->table('plist'), $field_arrs, 'INSERT');

                                                 }

                                            

                                      
                                       
                                           // print_r($value['D']);
                                        
                                               
                                               
                                        // if($fromData[order_status] && $fromData[order_status] != $value['I'] ){
                                                    
                                        //                 $field_arr['clearing_time'] = $value['Q'];
                                                    
                                        //                 $field_arr['order_status'] = $value['I'];
                                                    
                                                    
                                        //             // $db->autoExecute($ecs->table('cql'), $field_arr, 'INSERT');
                                        //                 $db->autoExecute($ecs->table('cql'), $field_arr, 'UPDATE', "order_sn = $value[Y] AND goods_id = $value[D] ", 'SILENT');
                                        //         }
                                        

                                       
                                       
                                        // print_r($key);
                                            

                                        
                                        
                                        
                                    } //foreach
                                }else{
                                    die('No Excel!');
                                }
        }
        else {
         die('请上传文件!');
    
    }

     /* 显示提示信息，返回商品列表 */
   // $link[] = array('href' => 'cql.php?act=add', 'text' => '成功');
  //  sys_msg($_LANG['batch_upload_ok'], 0, $link);
   // die('成功!');
     ecs_header("Location: index2.php\n");
     exit;
            
}

elseif ($action == 'order_query')
{
              $filter['order_settlement'] = $_REQUEST['order_settlement'] <= 1 ? 1 : trim($_REQUEST['order_settlement']);

          $filter['order_agent_name'] = $_REQUEST['order_agent_name'] == 1 ? '' : trim($_REQUEST['order_agent_name']);
          $is_agent_name_up   = explode("-",$_REQUEST['order_agent_name']) ;
          $filter['order_agent_name_up'] = $is_agent_name_up[1] ? $is_agent_name_up[1] : 0;
        //$filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['order_create_date'] = empty($_REQUEST['order_create_date']) == 1  ? '' : trim($_REQUEST['order_create_date']);
  $filter['order_condition'] = $_REQUEST['order_condition'] == 2  ? 2 : 1;

   
     $sql = "SELECT last_update FROM " . $ecs->table('cql') . " ORDER BY order_id DESC LIMIT 1";
     $lastUpdate = $db->getOne($sql);
   
    $smarty->assign('lastUpdate',   $lastUpdate);
    $order_list = order_list();
    $smarty->assign('order_list',   $order_list['orders']);
    $smarty->assign('filter',       $order_list['filter']);
    $smarty->assign('record_count', $order_list['record_count']);
    $smarty->assign('page_count',   $order_list['page_count']);
    $smarty->assign('total_price',   $order_list['total_price']);
        $smarty->assign('total_price_agent',   $order_list['total_price']/2);
        $smarty->assign('total_price_agent_up',   $order_list['total_price']*0.2);
        $smarty->assign('order_agent_name_up',   $filter['order_agent_name_up']);
    
    $smarty->assign('order_agent_name',   $filter['order_agent_name']);
    $smarty->assign('order_create_date',   $filter['order_create_date']);
    $smarty->assign('order_settlement',   $filter['order_settlement']);
        $smarty->assign('order_condition',   $filter['order_condition']);


    
   // print_r(order_list());
  $smarty->display('cql.dwt');
}

elseif ($action == 'order_query2')
{
              $filter['order_settlement'] = $_REQUEST['order_settlement'] == 1 ? '' : trim($_REQUEST['order_settlement']);

          $filter['order_agent_name'] = $_REQUEST['order_agent_name'] == 1 ? '' : trim($_REQUEST['order_agent_name']);
        //$filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['order_create_date'] = empty($_REQUEST['order_create_date']) == 1  ? '' : trim($_REQUEST['order_create_date']);
   
     $sql = "SELECT last_update FROM " . $ecs->table('cql') . " ORDER BY order_id DESC LIMIT 1";
     $lastUpdate = $db->getOne($sql);
   
    $smarty->assign('lastUpdate',   $lastUpdate);
    $order_list = order_list();
    $smarty->assign('order_list',   $order_list['orders']);
    $smarty->assign('filter',       $order_list['filter']);
    $smarty->assign('record_count', $order_list['record_count']);
    $smarty->assign('page_count',   $order_list['page_count']);
    $smarty->assign('total_price',   $order_list['total_price']);
    $smarty->assign('order_agent_name',   $filter['order_agent_name']);
    $smarty->assign('order_create_date',   $filter['order_create_date']);
    $smarty->assign('order_settlement',   $filter['order_settlement']);
    

    
   // print_r(order_list());
  $smarty->display('cql.dwt');
}

elseif ($action == 'order_merge')
{
            order_merge();
}


/**
 *  获取用户指定范围的订单列表
 *
 * @access  public
 * @param   int         $user_id        用户ID号
 * @param   int         $num            列表最大数量
 * @param   int         $start          列表起始位置
 * @return  array       $order_list     订单列表
 */
function get_user_orders($user_id='all', $date = 0, $start = 0)
{
    /* 取得订单列表 */
    $arr    = array();

    $sql = "SELECT * " .
           " FROM " .$GLOBALS['ecs']->table('cql') .
           " WHERE user_id = '$user_id' ORDER BY last_update DESC";
    $res = $GLOBALS['db']->SelectLimit($sql);

    while ($row = $GLOBALS['db']->fetchRow($res))
    {
        

        

        $arr[] = array('order_id'       => $row['order_id'],
                       'order_sn'       => $row['order_sn'],
                       'create_time'     => $row['create_time'],
                       'clearing_time'     => $row['clearing_time'],
                       'goods_name'   => $row['goods_name'],
                       'goods_number'       => $row['goods_number'],
                       'goods_price'     => $row['goods_price'],
                       'order_status'   => $row['order_status'],
                       'pay_price'       => $row['pay_price'],
                       'estimated_income'     => $row['estimated_income'],
                       'commission_ratio'   => $row['commission_ratio'],
                       'category_name'   => $row['category_name'],
                       'agent_name'        => $row['agent_id']);
    }

    return $arr;
}

/**
 *  获取订单列表信息
 *
 * @access  public
 * @param
 *
 * @return void
 */
function order_list()
{
    // if ($result === false)
    // {
        /* 过滤信息 */
        $filter['order_agent_name'] = $_REQUEST['order_agent_name'] == 1 ? '' : trim($_REQUEST['order_agent_name']);
        //$filter['mobile'] = empty($_REQUEST['mobile']) ? 0 : intval($_REQUEST['mobile']);
        $filter['order_create_date'] = empty($_REQUEST['order_create_date'])  ? '' : trim($_REQUEST['order_create_date']);

        $filter['order_settlement'] = $_REQUEST['order_settlement'] <=1  ? 1 : trim($_REQUEST['order_settlement']);
        $filter['order_condition'] = $_REQUEST['order_condition'] == 2   ? 2 : 1;

        

        $date = date('Y-m-d H:i:s'); //当前时间
        $today = date('Y-m-d');
        $yestdate = date("Y-m-d",strtotime("-1 day"));
        $firstmonthday = date('Y-m-01', strtotime($date));
        //$lastday = date('Y-m-d', strtotime("$firstday +1 month -1 day"));
        $lastmonthFDay =  date('Y-m-01', strtotime('-1 month'));
        $lastmonthEDay =  date('Y-m-t', strtotime('-1 month'));
        $year=date("Y",time());
        $firstyearday=$year."-01-01";
        //print_r($firstyearday);

        $where = 'WHERE 1 ';



        if ($filter['order_agent_name'])
        {
            if($filter['order_agent_name']=='小程序默认'){
                 $where .= " AND ( c.agent_name LIKE '%" . mysql_like_quote($filter['order_agent_name']) . "%' OR c.agent_name LIKE '%" . mysql_like_quote("小程序公共") . "%'  ) " ;
            }else{
                $is_order_agent_name = explode("-",$filter['order_agent_name']);
            $where .= " AND c.agent_name LIKE '%" . mysql_like_quote($is_order_agent_name[0]) . "%'";
            }
        }
        if ($filter['order_settlement']==1)
        {
            $where .= " AND order_status != '订单失效' ";
        }
        if ($filter['order_settlement']==2)
        {
            $where .= " AND c.clearing_time = '' AND order_status != '订单失效' ";
        }
        if ($filter['order_settlement']==3)
        {
            $where .= " AND c.clearing_time >1 AND order_status != '订单失效' ";
        }
        if ($filter['order_settlement']==4)
        {
            $where .= "  AND order_status = '订单失效' ";
        }


        //去掉微信推广方式渠道
            $where .= " AND c.agent_name NOT LIKE '%微信推广%' AND c.agent_name NOT LIKE '%taovips高佣金%' AND c.agent_name NOT LIKE '%taovips普通%' AND c.agent_name NOT LIKE '%导购公共%' AND c.agent_name != ''";



        
        //  if ($filter['order_create_date'] == 2)
        // {
        //     $where .= " AND c.create_time >= '$lastmonthFDay' AND  c.create_time <= '$lastmonthEDay' " ;
        // } elseif ($filter['order_create_date'] == 12) {
        //    $where .= " AND c.create_time >= '$firstyearday'";
        // }else{
        //     $where .= " AND c.create_time >= '$today'";
        // }

         switch($filter['order_create_date'])
        {
            case 2 :
                 $where .= " AND c.create_time >= '$yestdate' AND  c.create_time < '$today' " ;
                break;

           case 30 :
                $where .= " AND c.create_time >= '$firstmonthday'";
                break;
                 case 60 :
                 $where .= " AND c.create_time >= '$lastmonthFDay' AND  c.create_time <= '$lastmonthEDay' " ;
                break;
                 case 365 :
                $where .= " AND c.create_time >= '$firstyearday'";
                break;
            default:
                $where .= " AND c.create_time >= '$today'";
        }
        
        // if ($filter['mobile'])
        // {
        //     $where .= " AND o.mobile LIKE '%" .mysql_like_quote($filter['mobile']) . "%'";
        // }
        // if ($filter['country'])
        // {
        //     $where .= " AND o.country = '$filter[country]'";
        // }
        // if ($filter['province'])
        // {
        //     $where .= " AND o.province = '$filter[province]'";
        // }
        // if ($filter['city'])
        // {
        //     $where .= " AND o.city = '$filter[city]'";
        // }
        // if ($filter['district'])
        // {
        //     $where .= " AND o.district = '$filter[district]'";
        // }
        // if ($filter['shipping_id'])
        // {
        //     $where .= " AND o.shipping_id  = '$filter[shipping_id]'";
        // }
        // if ($filter['pay_id'])
        // {
        //     $where .= " AND o.pay_id  = '$filter[pay_id]'";
        // }
        // if ($filter['order_status'] != -1)
        // {
        //     $where .= " AND o.order_status  = '$filter[order_status]'";
        // }
        // if ($filter['shipping_status'] != -1)
        // {
        //     $where .= " AND o.shipping_status = '$filter[shipping_status]'";
        // }
        // if ($filter['pay_status'] != -1)
        // {
        //     $where .= " AND o.pay_status = '$filter[pay_status]'";
        // }
        // if ($filter['user_id'])
        // {
        //     $where .= " AND o.user_id = '$filter[user_id]'";
        // }
        // if ($filter['user_name'])
        // {
        //     $where .= " AND u.user_name LIKE '%" . mysql_like_quote($filter['user_name']) . "%'";
        // }
        // if ($filter['start_time'])
        // {
        //     $where .= " AND o.add_time >= '$filter[start_time]'";
        // }
        // if ($filter['end_time'])
        // {
        //     $where .= " AND o.add_time <= '$filter[end_time]'";
        // }

        //综合状态
        // switch($filter['order_status'])
        // {
        //     case '订单付款' :
        //         $where .= order_query_sql('await_pay');
        //         break;

        //    case '订单结算' :
        //         $where .= order_query_sql('await_pay');
        //         break;
        //     default:
        //         if ($filter['composite_status'] != -1)
        //         {
        //             $where .= " AND c.order_status = '$filter[composite_status]' ";
        //         }
        // }

       

       

        /* 分页大小 */
        $filter['page'] = empty($_REQUEST['page']) || (intval($_REQUEST['page']) <= 0) ? 1 : intval($_REQUEST['page']);

        // if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0)
        // {
        //     $filter['page_size'] = intval($_REQUEST['page_size']);
        // }
        // elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0)
        // {
        //     $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']);
        // }
        // else
        // {
        //     $filter['page_size'] = 150;
        // }
        $filter['page_size'] = 15000;
        /* 记录总数 */
        if ($filter['user_name'])
        {
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('cql') . " AS c ,".
                $GLOBALS['ecs']->table('users') . " AS u " . $where;
        }
        else
        {
            $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('cql') . " AS c ". $where .
            "   ";
        }

        $filter['record_count']   = $GLOBALS['db']->getOne($sql);
        $filter['page_count']     = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1;

        /* 查询 */
        $sql = "SELECT * " .
           
            " FROM " . $GLOBALS['ecs']->table('cql') . " AS c " . $where .
            //" LEFT JOIN " .$GLOBALS['ecs']->table('users'). " AS u ON u.user_id=o.user_id ". $where .
           // " ORDER BY $filter[sort_by] $filter[sort_order] ";
            "   ORDER BY create_time DESC ";
           // " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",$filter[page_size]";

       
       // set_filter($filter, $sql);
    // }
    // else
    // {
    //     $sql    = $result['sql'];
    //     $filter = $result['filter'];
    // }

    $row = $GLOBALS['db']->getAll($sql);

    //总价
    $total_price = '';
    $row_id = 0;
    /* 格式话数据 */


             foreach ($row AS $key => $value)
                {   
                    if ($filter['order_condition'] == 2){
                        $is_agent = $value['agent_name'] == '小程序张凤珍' || $value['agent_name'] == '小程序陈丽' ||  $value['agent_name'] == '小程序张雅丹' || $value['agent_name'] == '小程序岑少凤'  ? 1 : 0 ;
                        if(($value['create_time'] <= '2018-01-14 00:00' && $value['agent_name'] == '小程序公共') || $is_agent  )
            
                            {   
                                 $row[$key] = null;
                               
                            }
                            else{
                                  $row_id ++;
                                  $row[$key]['row_id'] = $row_id  ;
                                  $total_price += $value['estimated_income'];

                            }

      
            
                     }
                     else {
                        $row_id ++;
                        $row[$key]['row_id'] = $row_id  ;
                        $row[$key]['order_id'] = $value['order_id'];
                        $row[$key]['order_sn'] = $value['order_sn'];
                        $row[$key]['create_time'] = $value['create_time'];
                        $row[$key]['clearing_time'] = $value['clearing_time'];
                        $row[$key]['goods_id'] = $value['goods_id'];
                        $row[$key]['goods_name'] = $value['goods_name'];
                        $row[$key]['goods_number'] = $value['goods_number'];
                        $row[$key]['goods_price'] = $value['goods_price'];
                        $row[$key]['order_status'] = $value['order_status'];
                        $row[$key]['pay_price'] = $value['pay_price'];
                        $row[$key]['estimated_income'] = $value['estimated_income'];
                        $row[$key]['commission_ratio'] = $value['commission_ratio'];
                        $row[$key]['category_name'] = $value['category_name'];
                        $row[$key]['agent_name'] = $value['agent_name'];
                        $total_price += $value['estimated_income'];
                     }
                    
                }

        
            
 
   


    $arr = array('orders' => $row, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count'],'total_price'=> $total_price);

    return $arr;
}

function order_merge()
{
    


      $where = 'WHERE 1 ';

        /* 查询 */
        $sql = "SELECT * " .
           
            " FROM " . $GLOBALS['ecs']->table('cql_orders') . "  " . $where .
            //" LEFT JOIN " .$GLOBALS['ecs']->table('users'). " AS u ON u.user_id=o.user_id ". $where .
           // " ORDER BY $filter[sort_by] $filter[sort_order] ";
            " AND userId = 0  ";
           // " LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ",$filter[page_size]";

       
       // set_filter($filter, $sql);
    // }
    // else
    // {
    //     $sql    = $result['sql'];
    //     $filter = $result['filter'];
    // }

    $row = $GLOBALS['db']->getAll($sql);

        print_r("<pre>");
        // print_r($row);

     foreach ($row AS $key => $value)
                                {
                                    
                                        
                                      /* 查询 */
        $sql = "SELECT order_sn , agent_name " .
           
            " FROM " . $GLOBALS['ecs']->table('cql') . "  " . $where .
            " AND order_sn = $value[orderId]  ";
                                       $orderArry = $GLOBALS['db']->getRow($sql);     
                                            //print_r($orderArry);
                                          if($orderArry){
                                              
                                                $GLOBALS['db']->query("UPDATE " . $GLOBALS['ecs']->table('cql_orders') . " SET agent = '$orderArry[agent_name]' " .
                                                 "WHERE rowid = $value[rowid]");
                                                  print_r($value[rowid]);

                                          }  else{
                                              print_r(0);
                                          }  
                                            

                                              

                                                 


                                            

                                      

                                        
                                        
                                        
                                    } //foreach


    // ecs_header("Location: index.php\n");
    //     exit;
}



/**
*  数据导入
* @param string $file excel文件
* @param string $sheet
 * @return string   返回解析数据
 * @throws PHPExcel_Exception
 * @throws PHPExcel_Reader_Exception
*/
function importExecl($file='', $sheet=0){
	$file = iconv("utf-8", "gb2312", $file);   //转码
	if(empty($file) OR !file_exists($file)) {
		die('file not exists!');
	}
	//include('PHPExcel.php');  //引入PHP EXCEL类
	$objRead = new PHPExcel_Reader_Excel2007();   //建立reader对象
	if(!$objRead->canRead($file)){
		$objRead = new PHPExcel_Reader_Excel5();
		if(!$objRead->canRead($file)){
			die('No Excel!');
		}
	}

	$cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ');

	$obj = $objRead->load($file);  //建立excel对象
	$currSheet = $obj->getSheet($sheet);   //获取指定的sheet表
	$columnH = $currSheet->getHighestColumn();   //取得最大的列号
	$columnCnt = array_search($columnH, $cellName);
	$rowCnt = $currSheet->getHighestRow();   //获取总行数

	$data = array();
	for($_row=1; $_row<=$rowCnt; $_row++){  //读取内容
		for($_column=0; $_column<=$columnCnt; $_column++){
			$cellId = $cellName[$_column].$_row;
			$cellValue = $currSheet->getCell($cellId)->getValue();
             //$cellValue = $currSheet->getCell($cellId)->getCalculatedValue();  #获取公式计算的值
			if($cellValue instanceof PHPExcel_RichText){   //富文本转换字符串
				$cellValue = $cellValue->__toString();
			}

			$data[$_row][$cellName[$_column]] = $cellValue;
		}
	}

	return $data;
}

 

?>